import 'package:flutter/material.dart';
import '../public.dart';

class HeaderComponent extends StatefulWidget {
  final AnimationController controller;
  final Widget child;
  HeaderComponent({Key key, this.controller, this.child}) : super(key: key);

  @override
  _InState createState() {
    return _InState();
  }
}

class _InState extends State<HeaderComponent> with TickerProviderStateMixin {
  FocusNode searchF = new FocusNode();
  TextEditingController searchC = new TextEditingController();
  UserProvider user;

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    user = Provider.of<UserProvider>(context);
    return Positioned(
        left: 0,
        right: 8,
        top: 40,
        child: Container(
          width: double.infinity,
          height: 44,
          child: Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              BackComponent(),
              Expanded(
                  child: GestureDetector(
                      onTap: () {
                        Routers.navigateTo(RouterPage.SORT_MAIN_PAGE);
                      },
                      child: Container(
                          height: 32,
                          margin: EdgeInsets.only(left: 16, right: 24),
                          padding: EdgeInsets.only(left: 16),
                          decoration: BoxDecoration(
                              color: Color(0x5a000000),
                              borderRadius:
                                  BorderRadius.all(Radius.circular(16))),
                          child: Row(
                            children: [
                              SVG.svg('input_search', size: 14),
                              SizedBox(width: 4),
                              Text(
                                '斗破苍穹',
                                style: TextStyle(
                                    color: Colors.white, fontSize: 12),
                              )
                            ],
                          )))),
              GestureDetector(
                  onTap: () {
                    Routers.navigateTo(RouterPage.MY_INDEX);
                  },
                  child: Center(
                      child: ClipRRect(
                          borderRadius: BorderRadius.circular(16),
                          child: ImagesNetworkComponent(user.data?.uhead,
                              placeholder: 'assets/images/mrtx_qumh88.png',
                              width: 32,
                              height: 32)))),
            ],
          ),
        ));
  }
}
